package com.vehicle.app.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author shouhan
 * @version 1.0
 * @date 2018/12/28
 * @desc 自定义拦截器
 * @see
 * @since 1.0
 */
public class MyInterceptorAdapter extends HandlerInterceptorAdapter {

    private static final Logger LOGGER = LoggerFactory.getLogger(HandlerInterceptorAdapter.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("[preHandle] handler...");
        }
        return true;
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("[afterCompletion] handler...");
        }
        System.out.println("进入全局拦截。。。。");
        //todo 王寿汉 项目访问日志
        System.out.println("地址" + request.getRequestURI());
    }
}
